import wei.yigulu.iec104.annotation.AsduType;
import wei.yigulu.iec104.apdumodel.Apdu;
import wei.yigulu.iec104.asdudataframe.ShortFloatCommand;

import java.math.BigDecimal;

@AsduType(typeId = 50)
public class MyShortFloatCommand extends ShortFloatCommand {
    @Override
    public byte[][] handleAndAnswer(Apdu apdu) throws Exception {
        ShortFloatCommand shortFloatCommand = (ShortFloatCommand) apdu.getAsdu().getDataFrame();
        if (shortFloatCommand.getAddresses().getAddress() == 1) {
            ProtocolDataContainer.getInstance().putNumber(16393, BigDecimal.valueOf(shortFloatCommand.getVal()));
        } else {
            ProtocolDataContainer.getInstance().putNumber(16394, BigDecimal.valueOf(shortFloatCommand.getVal()));
        }
        return super.handleAndAnswer(apdu);
    }
}
